package com.example.excelgenera.controller;

import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class GreetingController {

    @MessageMapping("/hello")
    @SendTo("/topic/greetings")
    public  Greeting greeting(HelloMessage message) throws Exception {
        Thread.sleep(1000); // simulated delay
        return new Greeting("Hello, " + message.getName() + "!");
    }

    @GetMapping("home2")
    public HelloMessage bb() throws Exception {
         HelloMessage helloMessage = new HelloMessage();
        helloMessage.setName("bbb");
        greeting(helloMessage);
        return helloMessage;
    }
}